#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void *thread_start_routine(void *argv)
{
    char *str = argv;
    printf("我是子线程，主线程给我的参数为%s\n", str);
    char *buf = malloc(9);
    strcpy(buf, "THREAD 2");
    return (void *)buf;
}

int main(int argc, char const *argv[])
{
    pthread_t thread;
    pthread_create(&thread, NULL, thread_start_routine, "Thread 1");
    printf("我是主线程\n");

    void *a;
    pthread_join(thread, &a);
    printf("子线程的返回值为 %s\n", (char *)a);
    free(a);

    return 0;
}
